<%@ page import="com.user.entity.Page" %>
<%@ page import="com.user.entity.BookInfo" %>
<%@ page import="java.util.List" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">


<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>书籍列表</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="../assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="../assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="http://cdn.bootcss.com/echarts/3.3.2/echarts.min.js"></script>
    <link rel="stylesheet" href="../assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="../assets/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href="../assets/css/app.css">
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>

</head>

<body data-type="widgets">

<script src="../assets/js/theme.js"></script>
<div class="am-g tpl-g">
    <!-- 头部 -->
    <header>
        <!-- logo -->
        <div class="am-fl tpl-header-logo">
            <a href="javascript:;"><img src="../assets/img/logo1.png" alt=""></a>
        </div>
        <!-- 右侧内容 -->
        <div class="tpl-header-fluid">
            <!-- 侧边切换 -->
            <div class="am-fl tpl-header-switch-button am-icon-list">
                    <span>

                </span>
            </div>

            <!-- 其它功能-->
            <div class="am-fr tpl-header-navbar">
                <ul>
                    <!-- 欢迎语 -->
                    <li class="am-text-sm tpl-header-navbar-welcome">
                        <a href="javascript:;">欢迎你, <span>${sessionScope.adminname}</span> </a>
                    </li>


                </ul>
                </li>

                <!-- 新提示 -->

                <!-- 退出 -->
                <li class="am-text-sm">
                    <a href="../User/userLogin.jsp">
                        <span class="am-icon-sign-out"></span> 退出
                    </a>
                </li>
                </ul>
            </div>
        </div>

    </header>
    <!-- 风格切换 -->
    <div class="tpl-skiner">
        <div class="tpl-skiner-toggle am-icon-cog">
        </div>
        <div class="tpl-skiner-content">
            <div class="tpl-skiner-content-title">
                选择主题
            </div>
            <div class="tpl-skiner-content-bar">
                <span class="skiner-color skiner-white" data-color="theme-white"></span>
                <span class="skiner-color skiner-black" data-color="theme-black"></span>
            </div>
        </div>
    </div>
    <!-- 侧边导航栏 -->
    <div class="left-sidebar">
        <!-- 用户信息 -->
        <div class="tpl-sidebar-users-panel">
            <div class="tpl-users-panel-slide-toggleable">
                <div class="tpl-users-panel-profile-picture" align="center">
                    <img src="../assets/img/user07.png" alt="">
                </div>
                <span class="users-panel-logged-in-text">
              <div align="center">
                  <i class="am-icon-circle-o am-text-success tpl-users-panel-status-icon"></i>
                  <font color="#a4ff7f" size="20">${sessionScope.adminname}</font></div>
          </span>
                <br>
                <a href="../User/updateUI.jsp" class="tpl-users-panel-action-link">
                    <span class="am-icon-pencil"></span> 账号设置</a>
            </div>
        </div>

        <!-- 菜单 -->

        <!-- 菜单 -->

        <li class="sidebar-nav-heading">数据
            <%-- <span class="sidebar-nav-heading-info"> 常用页面</span></li>--%>
        <li class="sidebar-nav-link">
            <a href="javascript:;" class="sidebar-nav-sub-title active">
                <i class="am-icon-table sidebar-nav-link-logo"></i> 数据列表
                <span class="am-icon-chevron-down
                am-fr
                am-margin-right-sm
                sidebar-nav-sub-ico
                sidebar-nav-sub-ico-rotate"></span>

            </a>
            <ul class="sidebar-nav sidebar-nav-sub" style="display: block;">
                <li class="sidebar-nav-link">
                    <a href="/UserListServlet">
                        <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 用户列表
                    </a>
                </li>

                <li class="sidebar-nav-link">
                    <a href="/SchoolListServlet">
                        <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 合作学校列表
                    </a>
                </li>
                <li class="sidebar-nav-link">
                    <a href="BookListServlet?adminname=${sessionScope.adminname}" class="sub-active">
                        <span class="am-icon-angle-right sidebar-nav-link-logo"></span> 书籍列表
                    </a>
                </li>
            </ul>
        </li>
        <li class="sidebar-nav-link">

        </li>
        <li class="sidebar-nav-link">
            <a href="../User/userLogin.jsp">
                <i class="am-icon-key sidebar-nav-link-logo"></i> 登录其他账户
            </a>
        </li>


        </ul>
    </div>

    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">书籍列表</div>


                        </div>
                        <div class="widget-body  am-fr">

                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                <div class="am-form-group">
                                    <div class="am-btn-toolbar">
                                        <div class="am-btn-group am-btn-group-xs">
                                            <button id="registerBt" type="button" href="../User/queryForm.jsp"
                                                    class="am-btn am-btn-default am-btn-success"><span
                                                    class="am-icon-plus"></span> <a href="../Admin/queryBookForm.jsp">
                                                查询书籍</a>
                                            </button>
                                            <button id="registerBt" type="button" href="../User/queryForm.jsp"
                                                    class="am-btn am-btn-default am-btn-danger"><span
                                                    class="am-icon-plus"></span> <a href="../Admin/addBooksForm.jsp">
                                                添加书籍</a>
                                            </button>


                                            <%-- <button type="button" class="am-btn am-btn-default am-btn-danger"><span
                                                     class="am-icon-trash-o"></span> 删除
                                             </button>--%>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                                <div class="am-form-group tpl-table-list-select">

                                </div>
                            </div>
                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                                <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">

                                    <span class="am-input-group-btn">
                                <input type="text" class="am-form-field " value="${msg}">
                                </span>
                                </div>
                            </div>

                            <div class="am-u-sm-12">
                                <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black "
                                       id="example-r">
                                    <thead>
                                    <tr>
                                        <th>书籍号</th>
                                        <th>书籍名</th>
                                        <th>作者</th>
                                        <th>类别</th>
                                        <th>存量</th>
                                        <th>操作</th>

                                    </tr>
                                    </thead>
                                    <!-- gradeX  even gradeC -->
                                    <tbody>


                                    <%
                                        //获取request中的数据
                                        request.setCharacterEncoding("utf-8");
                                        Page bookListPage = (Page) request.getAttribute("p");

                                        List<BookInfo> bookList = bookListPage.getBookList();
                                        for (BookInfo bookInfo : bookList) {

                                    %>
                                    <tr class="gradeX">
                                        <td>
                                            <a href="#"><%= bookInfo.getBookid()%>
                                            </a>
                                        </td>
                                        <td>
                                            <%=bookInfo.getBookname()%>
                                        </td>
                                        <td>
                                            <%=bookInfo.getAuthor()%>
                                        </td>

                                        <td>
                                            <%=bookInfo.getCategory()%>
                                        </td>

                                        <td>
                                            <%=bookInfo.getNumber()%>
                                        </td>
                                        <!--
                                        按钮
                                        -->
                                        <td>
                                            <div class="tpl-table-black-operation">
                                                <a href="/GetBookInfoServlet?id=<%=bookInfo.getBookid()%>"
                                                   class="tpl-table-black-operation-del">
                                                    <i class="am-icon-edit"></i> 编辑
                                                </a>

                                            </div>
                                        </td>
                                    </tr>
                                    <%
                                        }
                                    %>


                                    </tbody>
                                </table>
                            </div>

                            <div class="am-u-lg-12 am-cf">

                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        <%
                                            String adminname = (String) request.getSession().getAttribute("adminname");
                                        %>

                                        <c:choose>
                                            <c:when test="${requestScope.p.currentPage==1}">
                                                <li class="am-active"><a href="#">${requestScope.p.currentPage}</a></li>


                                                <%
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=" +
                                                            (bookListPage.getCurrentPage() + 1) + "\">下一页</a></li>\n");
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=" +
                                                            (bookListPage.getTotalPage()) + "\">尾页</a>\n</li>");
                                                %>
                                            </c:when>
                                            <c:when test="${requestScope.p.currentPage!=1&&requestScope.p.currentPage!=requestScope.p.totalPage}">
                                                <%
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=1\">首页</a></li>");
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=" +
                                                            (bookListPage.getCurrentPage() - 1) + "\">上一页</a></li>\n");
                                                %>
                                                <li class="am-active"><a href="#">${requestScope.p.currentPage}</a></li>

                                                <%
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=" +
                                                            (bookListPage.getCurrentPage() + 1) + "\">下一页</a></li>\n");
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=" +
                                                            (bookListPage.getTotalPage()) + "\">尾页</a>\n</li>");
                                                %>
                                            </c:when>

                                            <c:when test="${requestScope.p.currentPage==requestScope.p.totalPage}">
                                                <%
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=1\">首页</a></li>");
                                                    out.print("<li><a href=\"/BookListServlet?adminname=" + adminname + "&&currentPage=" +
                                                            (bookListPage.getCurrentPage() - 1) + "\">上一页</a></li>\n");
                                                %>
                                                <li class="am-active"><a href="#">${requestScope.p.currentPage}</a></li>

                                            </c:when>


                                        </c:choose>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<script src="http://cdn.bootcss.com/amazeui/2.7.2/js/amazeui.min.js"></script>
<script src="../assets/js/amazeui.datatables.min.js"></script>
<script src="../assets/js/dataTables.responsive.min.js"></script>
<script src="../assets/js/app.js"></script>

</body>

</html>
